home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / XLisp-Stat / Functions / rotatecoordaxis.lsp < prev    next >
Text File  |  1990-10-11  |  1KB  |  29 lines

  1. ; book pp.320-321
  2.  
  3. (require "functions/twobutton")
  4.  
  5. (defmeth spin-proto :set-axis-rotation(v)
  6.   (let* ((m (send self :num-variables))
  7.          (v1 (if (= v 0) 1 0))
  8.          (v2 (if (= v 2) 1 2))
  9.          (trans (send self :transformation))
  10.          (cols (column-list (if trans trans (identity-matrix m))))
  11.          (x1 (select cols v1))
  12.          (x2 (select cols v2))
  13.          (angle (send self :angle)))
  14.     (send self :rotation-type (make-rotation x1 x2 angle))))
  15. (defproto spin-rotate-control-proto '(v) () twobutton-control-proto)
  16. (defmeth spin-rotate-control-proto :isnew (v &rest args)
  17.   (apply #'call-next-method :v v args))
  18. (defmeth spin-rotate-control-proto :title ()
  19.   (send (send self :graph) :variable-label (slot-value 'v)))
  20. (defmeth spin-rotate-control-proto :do-action (sign mods)
  21.   (let ((graph (send self :graph)))
  22.     (if mods
  23.       (let ((v (slot-value 'v))
  24.             (angle (abs (send graph :angle))))
  25.         (send graph :idle-on (first mods))
  26.         (send graph :angle (if (eq sign '+) angle (- angle)))
  27.         (send graph :set-axis-rotation v)))
  28.     (send graph :rotate)))
  29.